home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / HD / SmartFileSystem / V1.58 / Sources / fs / objects.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-24  |  8.7 KB  |  248 lines

  1. #include <exec/types.h>
  2. #include <libraries/iffparse.h>
  3. #include <utility/tagitem.h>
  4. #include "blockstructure.h"
  5. #include "nodes.h"
  6.  
  7. #define OBJECTCONTAINER_ID         MAKE_ID('O','B','J','C')
  8. #define HASHTABLE_ID               MAKE_ID('H','T','A','B')
  9. #define SOFTLINK_ID                MAKE_ID('S','L','N','K')
  10.  
  11. /* Below is the structure describing an Object.  Objects can be files or
  12.    directories.  Multiple Objects can be stored in an ObjectContainer
  13.    block.
  14.  
  15.    owneruid & ownergid:  These are not used at the moment.  They have
  16.    been reserved for future use.  They must be set to zero for now.
  17.  
  18.    objectnode:  This field contains a number uniquely identifying this
  19.    object.  This number can be used to find out the ObjectContainer
  20.    where the Object is stored in.  It is used to refer to an Object
  21.    without having to use BLCK pointers.
  22.  
  23.    protection:  Contains the Object's protection bits.  By default this
  24.    field is set to 0x0000000F, which means bits R, W, E and D are set
  25.    (note that this is opposite to what is used by AmigaDOS).
  26.  
  27.    data (files only):  Contains the BLCK number of the first data block of
  28.    a file.  To find out where the rest of the data is located this BLCK
  29.    number can be looked up in a special B+-Tree structure (see below).
  30.  
  31.    size (files only):  Contains the size of a file in bytes.
  32.  
  33.    hashtable (directories only):  A BLCK pointer.  It points to a
  34.    HashTable block.
  35.  
  36.    firstdirblock (directories only):  This BLCK pointer points to the
  37.    first ObjectContainer block which belongs to this directory object.
  38.    For empty directories this field is zero.
  39.  
  40.    datemodified:  The date of the last modification of this Object.  The
  41.    date is stored in seconds from 1-1-1978 (enough for storing 136 years)
  42.  
  43.    bits:  See the defines below.  At the moment this field can be checked
  44.    to see if the object is a file or directory.  A bit is reserved for
  45.    links, but isn't currently used (and may or may not be used depending
  46.    on how and if links are implemented).
  47.  
  48.    name:  Directly following the main structure is the name of the object.
  49.    It is zero terminated.
  50.  
  51.    comment:  Directly following the name of the object is the comment
  52.    field.  This field is zero terminated as well (even if there is no
  53.    comment). */
  54.  
  55. struct fsObject {
  56.   UWORD owneruid;
  57.   UWORD ownergid;
  58.   NODE  objectnode;
  59.   ULONG protection;
  60.  
  61.   union {
  62.     struct {
  63.       BLCK  data;
  64.       ULONG size;
  65.     } file;
  66.  
  67.     struct {
  68.       BLCK  hashtable;   /* for directories & root, 0 means no hashblock */
  69.       BLCK  firstdirblock;
  70.     } dir;
  71.   } object;
  72.  
  73.   ULONG datemodified;
  74.   UBYTE bits;
  75.  
  76.   UBYTE name[0];
  77.   UBYTE comment[0];
  78. };
  79.  
  80. #define OTYPE_HIDDEN      (1)
  81. #define OTYPE_UNDELETABLE (2)
  82. #define OTYPE_QUICKDIR    (4)
  83. #define OTYPE_RINGLIST    (8)     /* Already partially implemented, but
  84.                                      doesn't seem to be very useful. */
  85. #define OTYPE_HARDLINK    (32)
  86. #define OTYPE_LINK        (64)
  87. #define OTYPE_DIR         (128)
  88.  
  89. /* hashtable can be zero as well.  If it is zero then the directory
  90.    does not have a hashblock.  This means looking up a file by name
  91.    will be slower since the system will fall-back to scanning the
  92.    complete directory.  However, file creation speed will be higher
  93.    (which includes moving a file to this directory, which happens
  94.    often with the Recycled directory for example). */
  95.  
  96. /* for all types of objects:
  97.    -------------------------
  98.  
  99.    HIDDEN: The Object won't be returned by EXAMINE_NEXT or
  100.            EXAMINE_ALL.
  101.  
  102.    UNDELETABLE: ACTION_DELETE_OBJECT will return an error for Objects
  103.                 protected by this bit.
  104.  
  105.    for directories only:
  106.    ---------------------
  107.  
  108.    QUICKDIR: Entries are added at the start of the directory without
  109.              checking if there is room anywhere else in the dir. */
  110.  
  111. /* SFS supports Soft links.  When OTYPE_LINK is set and OTYPE_HARDLINK is
  112.    clear then the entry is a soft link.  The path of the soft link isn't
  113.    stored with the directory entry, but instead is stored as the file
  114.    data. */
  115.  
  116.  
  117.  
  118. /* The fsObjectContainer structure is used to hold various Objects which
  119.    have the same parent directory.  Objects always start at 2-byte
  120.    boundaries, which means sometimes a padding byte is inserted between
  121.    2 fsObject structures.  The next & previous fields link all
  122.    ObjectContainers in a doubly linked list.
  123.  
  124.    parent:  The node-number of the parent Object.  The node number can be
  125.    used to lookup the BLCK number of the block where the parent Object is
  126.    located.
  127.  
  128.    next:  The next ObjectContainer belonging to this directory or zero if
  129.    it is the last in the chain.
  130.  
  131.    previous:  The previous ObjectContainer belonging to this directory or
  132.    zero if it is the first ObjectContainer.
  133.  
  134.    object:  A variable number of fsObject structures, depending on their
  135.    sizes and on the size of the block.  The next object structure can be
  136.    found by creating a pointer pointing to the name field of the current
  137.    object, then skip 2 strings (name & comment) and if the address is odd,
  138.    adding 1. */
  139.  
  140. struct fsObjectContainer {
  141.   struct fsBlockHeader bheader;
  142.  
  143.   NODE parent;
  144.   BLCK next;
  145.   BLCK previous;   /* 0 for the first block in the directory chain */
  146.  
  147.   struct fsObject object[0];
  148. };
  149.  
  150.  
  151.  
  152. /* fsHashTable is the structure of a HashTable block.  It functions much
  153.    like the HashTable found in FFS, except that it is stored in a seperate
  154.    block.  This block contains a number of hash-chains (about 120 for a
  155.    512 byte block).  Each hash-chain is a chain of Nodes.  Each Node
  156.    contains a BLCK pointer to an Object and the node number of the next
  157.    entry in the hash-chain.
  158.  
  159.    parent:  The node-number of the parent object.
  160.  
  161.    hashentry:  The node-number of the first entry of a specific
  162.    hash-chain. */
  163.  
  164. struct fsHashTable {
  165.   struct fsBlockHeader bheader;
  166.  
  167.   NODE parent;
  168.  
  169.   NODE hashentry[0];
  170. };
  171.  
  172.  
  173.  
  174. struct fsSoftLink {
  175.   struct fsBlockHeader bheader;
  176.  
  177.   NODE parent;
  178.   BLCK next;
  179.   BLCK previous;
  180.  
  181.   UBYTE string[0];
  182. };
  183.  
  184.  
  185.  
  186. struct fsObjectNode {
  187.   struct fsNode node;
  188.   NODE  next;
  189.   UWORD hash16;
  190. };
  191.  
  192.  
  193.  
  194. /* Tags used by createobjecttags: */
  195.  
  196. #define COBASE            (TAG_USER)
  197.  
  198. #define CO_OBJECTNODE     (COBASE+1)   /* The ObjectNode of the object.  Defaults to creating a
  199.                                           new ObjectNode.  If an ObjectNode is passed then its
  200.                                           data field will be set to point to the block which
  201.                                           contains the new Object. */
  202.  
  203. #define CO_PROTECTION     (COBASE+2)   /* The protection bits of the object.  Defaults to
  204.                                           FIBF_READ|FIBF_WRITE|FIBF_EXECUTE|FIBF_DELETE. */
  205.  
  206. #define CO_DATEMODIFIED   (COBASE+3)   /* The modification data of the object.  Defaults to
  207.                                           current date. */
  208.  
  209. #define CO_OWNER          (COBASE+4)   /* The owneruid and ownergid of the object.  Default to
  210.                                           zero. */
  211.  
  212. #define CO_COMMENT        (COBASE+5)   /* Comment of the new object (79 chars max).  Defaults to
  213.                                           no comment. */
  214.  
  215. #define CO_BITS           (COBASE+6)   /* See bits in fsObject. */
  216.  
  217. #define CO_HASHOBJECT     (COBASE+7)   /* If not FALSE, then the new Object will be hashed
  218.                                           automatically.  Defaults to FALSE. */
  219.  
  220. #define CO_UPDATEPARENT   (COBASE+8)   /* If not FALSE, then the new Object's Parent's archive
  221.                                           bit will be cleared and its modification date will be
  222.                                           updated.  Defaults to FALSE. */
  223.  
  224. #define CO_ALLOWDUPLICATES (COBASE+9)  /* If not FALSE, then createobjecttags() won't check to
  225.                                           see if an object already exists.  Defaults to FALSE. */
  226.  
  227.   /* File specific tags: */
  228.  
  229. #define CO_SIZE           (COBASE+20)   /* The size of the file.  Defaults to zero.  Ignored if
  230.                                           CO_BITS indicates its a directory. */
  231.  
  232. #define CO_DATA           (COBASE+21)   /* The first block of the file.  Defaults to zero.
  233.                                           Ignored if CO_BITS indicates its a directory. */
  234.  
  235.   /* Directory specific tags: */
  236.  
  237. #define CO_FIRSTDIRBLOCK  (COBASE+30)  /* The first ObjectContainer of the directory.  Defaults
  238.                                           to zero.  Ignored if CO_BITS indicates its a file. */
  239.  
  240. #define CO_HASHBLOCK      (COBASE+31)  /* The Hashblock of the directory.  Defaults to creating
  241.                                           a new Hashblock.  Ignored if CO_BITS indicates its a
  242.                                           file. */
  243.  
  244.   /* Softlink specific tags: */
  245.  
  246. #define CO_SOFTLINK       (COBASE+40)  /* The Softlink string.  No default!  Ignored if CO_BITS
  247.                                           indicates its not a softlink. */
  248.